<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .note-editable {
            height: 150px
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">合同管理-新增合同</h2>
</div>
<!-- 标题 -->
<div class="row-margin-top">
    <form action="" class="form-inline">
        <table class="table-bordered table t_table text-center">
            <tr class="info">
                <th colspan="2" class="font-bold">合同基本信息</th>
            </tr>
            <tr>
                <td style="min-width: 180px;width: 180px"><label for="">合同主题<span class="colorRed">*</span>：</label>
                </td>
                <td class="text-left"><input type="text" class="form-control" style="min-width: 300px;width: 300px"
                                             name="htzt"></td>
            </tr>
            <tr>
                <td style="min-width: 180px;width: 180px"><label for="">合同类型<span class="colorRed">*</span>：</label>
                </td>
                <td class="text-left">
                    <select name="htlx" id="" class="form-control select" style="min-width: 220px;width: 220px">
                        <option value="0">请选择</option>
                        <option value="1">经销合同</option>
                        <option value="2">采购合同</option>
                        <option value="3">销售合同</option>
                        <option value="4">供应合同</option>
                        <option value="5">买卖合同</option>
                        <option value="6">服务合同</option>
                        <option value="7">其他合同</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="min-width: 180px;width: 180px"><label for="">合同签署方<span class="colorRed">*</span></label>
                </td>
                <td class="text-left">
                    <div class="form-group">
                        <label for="">我方名称：</label>
                        <select name="htqsf_wfmc" id="" class="form-control" style="min-width: 220px;width: 220px">
                            <option value="0">请选择</option>
                            <option value="1">经销合同</option>
                            <option value="2">采购合同</option>
                            <option value="3">销售合同</option>
                            <option value="4">供应合同</option>
                            <option value="5">买卖合同</option>
                            <option value="6">服务合同</option>
                            <option value="7">其他合同</option>
                        </select>
                    </div>
                    <br><br>
                    <div class="form-group">
                        <label for="">对方名称：</label>
                        <input type="text" class="form-control" style="min-width: 220px;width: 220px" name="htqsf_dfmc">
                    </div>
                </td>
            </tr>
            <tr>
                <td style="min-width: 180px;width: 180px"><label for="">合同金额<span class="colorRed">*</span>：</label>
                </td>
                <td class="text-left"><input type="text" class="form-control numReg" style="min-width: 160px;width: 160px" name="htje">元
                </td>
            </tr>
            <tr>
                <td style="min-width: 180px;width: 180px"><label for="">合同签订日期<span class="colorRed">*</span>：</label>
                </td>
                <td class="text-left"><input id="contract" class="laydate-icon form-control layer-date"
                                             style="min-width: 160px;width: 160px" name="htqdrq"></td>
            </tr>
            <tr>
                <td style="min-width: 180px;width: 180px"><label for="">合同有效期<span class="colorRed">*</span>：</label>
                </td>
                <td class="text-left">
                    <div class="form-group">
                        <input type="text" id="start" class="form-control layer-date " style="height: 26px;display: inline-block;" name="htyxq_ksrq">
                    </div>
                    <div class="form-group">
                        至
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control layer-date" style="height: 26px;display: inline-block;"
                               id="end" name="htyxq_jsrq">
                    </div>
                </td>
            </tr>
            <tr class="info">
                <td class="text-left font-bold" colspan="2">合同内容摘要<span class="colorRed">*</span>:</td>
            </tr>
            <tr>
                <td class="text-left" colspan="2">
                    <div class="ibox float-e-margins" style="margin-bottom: 0">
                        <div class="ibox-content no-padding">

                            <div class="summernote" id="htnrzy">

                            </div>

                        </div>
                    </div>
                </td>
            </tr>
            <tr class="info">
                <td class="text-left font-bold" colspan="2">合同详情<span class="colorRed">*</span>:</td>
            </tr>
            <tr>
                <td class="text-left" colspan="2">
                    <div class="ibox float-e-margins" style="margin-bottom: 0">
                        <div class="ibox-content no-padding">

                            <div class="summernote" id="htxq">

                            </div>

                        </div>
                    </div>
                </td>
            </tr>
            <tr class="info">
                <td class="text-left font-bold" colspan="2">备注:</td>
            </tr>
            <tr>
                <td colspan="2" class="text-left">
                    <textarea name="bz" id="" style="height: 50px;width: 90%;user-select:none;overflow:auto"></textarea><span
                        style="vertical-align: bottom;">400</span>
                </td>
            </tr>
            <tr class="info">
                <td class="text-left font-bold" colspan="2">合同审批人流程信息</td>
            </tr>
            <tr>
                <td colspan="2" class="text-left" style="position: relative;">
                    附件：支持上传附件<span class="glyphicon glyphicon-open" aria-hidden="true" style="margin-left: 5px;font-size: 20px"></span>
                    <div class="form-control" style="position: absolute;top: 0;left: 0;opacity: 0">
                        <input type="file" id="exampleInputFile" name="">
                    </div>
                </td>
            </tr>
        </table>

        <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
            <input type="button" class="btn btn-success save" id="save1" value="保存为草稿">
            <input type="button" class="btn btn-info save" id="save2" value="保存并提交流程">
            <input type="button" class="btn btn-warning" value="返回" onclick="back()">
        </div>
    </form>
</div>
<!-- 全局js -->
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<!--统计代码，可删除-->
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script>
    $(document).ready(function () {

        //保存
        $('.save').on('click',function () {
            var param = $(this).closest('form').serialize()
            var htnrzy = $('#htnrzy').code()
            var htxq = $('#htxq').code()
            param += '&htnrzy='+htnrzy
            param += '&htxq='+htxq
            var iid = $(this).prop('id')
            $.post('',param,function (data) {
                if(data.success){
                    if(iid=='save2'){
                        $.ajax({
                            typ:'post',
                            url:'{:url("tjgzl")}',
                            data:{id:data.id},
                            success:function (data) {
                                console.log(data)
                            },
                            dataType:'json',
                            async:false
                        })
                    }
                    swal({
                        title:data.msg,
                        type: "success"
                    },function () {
                        location.href='{:url("wdhtsq")}'
                    })
                }else{
                    swal(data.msg,'','warning')
                }
            },'json')
            return false
        })

        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });
    laydate({
        elem: '#contract', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        event: 'focus' //响应事件。如果没有传入event，则按照默认的click
    });
    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY-MM-DD',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);

    function back() {
        history.go(-1);
    }

    /*表单只能输出数字*/
    function keyPress(ob) {
        if (!ob.value.match(/^[\+\-]?\d*?\.?\d*?$/)) ob.value = ob.t_value; else ob.t_value = ob.value;
        if (ob.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/)) ob.o_value = ob.value;
    }

    var numReg = document.getElementsByClassName('numReg');
    console.log(numReg)
    for (var i = 0; i < numReg.length; i++) {
        numReg[i].onkeyup = function () {
            keyPress(this)
        }
    }
</script>
</body>

</html>
